1. /* sifbfact.cpp by K.Tsuru */
  2. // function ID 4102 BRADIX
  3. /*******************************************************
  4. SInteger class
  5. It provides the factorial n! using the primitive method.
  6. See BdFact().
  7. ********************************************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. SInteger BFact(ulong n){
  12. long fig = long( (double)Stirling(n)/log10((double)BRADIX) )+1;//the number of figures in BRADIX ver. 2.17
  13. if(fig >= (long)SNManager::SNMaxSize(SNManager::BIN_INT)){
  14. SNManager::SetError(SNManager::OUT_OF_RANGE, "BFact", 4102);
  15. }
  16. SInteger m((uint)fig, 1); // m = 1, allocates the memory
  17. if(n < 2uL) return m;
  18. ulong i;
  19. for(i = 2uL; i <= n; i++) IsMult(m, i, m);
  20. return m;
  21. }

sifbfact.cpp : last modifiled at 2015/12/05 20:12:13(730 bytes)
created at 2016/04/25 14:53:17
The creation time of this html file is 2017/10/25 11:09:45 (Wed Oct 25 11:09:45 2017).